/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	Buffer.h
*
*	Description -	Most basic form of buffer for graphics to use
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	07/26/2013	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_BUFFER_H_
#define _PSX_BUFFER_H_

#include "PulseSTD.h"
#include "GraphicsTypes.h"
#include "ShaderResource.h"
#include "GraphicsBuffer.h"
#include "ResourcePoolItem.h"
#include "ShaderResourceViewDesc.h"
#include "UnorderedAccessViewDesc.h"

namespace Pulse
{
	struct BufferDesc : public BaseResDesc
	{
		BufferDesc( void );

		void SetDefault( void );
		
		void Set( EGraphicsFormat::Type	format, SIZE_T numElements, EBufferUsage::Type usage, void *pInitialData = PSX_NULL, BOOL bAllowRawView = FALSE );

		virtual const ResourceCode GetType( void ) const { return ResourceCode( EResource::VIDEO, EVideoResource::BUFFER); }

		EGraphicsFormat::Type	m_format;
		UINT					m_numElements;
		EBufferUsage::Type		m_usage;
		BOOL					m_bAllowRawView;
		void					*m_pData;

		ShaderResourceViewDesc	m_srvDesc;
		UnorderedAccessViewDesc m_uavDesc;

	};

	class Buffer : public IResourcePoolItem, public ShaderResource, public GraphicsBuffer
	{
	public:

		virtual ~Buffer( void );

		// These defines the base interface for all derived resources
		virtual BOOL CreateResource( BaseResDesc *pDesc );
		virtual BOOL DestroyResource( void );
		virtual BOOL LoadResource( void );
		virtual BOOL UnloadResource( void );

		virtual const ResourceCode GetType( void ) const { return ResourceCode( EResource::VIDEO, EVideoResource::BUFFER); }

	public:

	private:

		Buffer( void );

		EErrorCode::Type Initialize( void );

		void Cleanup( void );

	private:

		PSX_MakeStoragePoolFriend( Buffer );

		BufferDesc	m_desc;
	};
}

#endif /* _PSX_BUFFER_H_ */